﻿<cfsilent>
	<cfscript>

		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		propertyAdvice = getProperty("serviceFactory").getBean("studentPropertyAdvice");
		
		depId = sessionAdvice.getUserProp("teacherDepartment");
		
		taskId = event.getArg("TSK");
		taskType = event.getArg("TT");
		termId = event.getArg("TermID", event.getArg("TID"));
	
		event.setArg("pageTitle", "学生选课管理 - 添加课程向导");
		
		currentTab = event.getArg("TabID", "labStudent");
		
		targetArgs = structNew();
		structInsert(targetArgs, "TID", termId, true);
		structInsert(targetArgs, "TSK", taskId, true);
		structInsert(targetArgs, "TT", taskType, true);
		
		studentId = event.getArg("STU");
		
		/* 搜索学生档案 */
		keyword = event.getArg("Keywords", studentId);

		rs_student = queryNew("stu_id");
		
		if ( len(keyword) ) {
			
			sql = "SELECT 
						t_student.stu_id, 
						t_student.stu_name, 
						t_class.cls_name, 
						t_student_status.student_prop 
					FROM 
						t_student 
						INNER JOIN t_class ON t_class.cls_id = t_student.cls_id 
						INNER JOIN t_student_status ON t_student_status.stu_id = t_student.stu_id 
						INNER JOIN t_subject ON t_subject.sbj_id = t_class.sbj_id 
					WHERE 
						( t_student.stu_id LIKE :condition OR t_student.stu_name LIKE :condition )
						AND 
						( t_class.grade + t_subject.schooling_length > :yearNow ) 
					ORDER BY 
						t_student.stu_name ";
			queryObj = new query( datasource=application.dnsSlave, maxRows=60 );
			queryObj.addParam( name="yearNow", value=year(now())-1, cfsqltype="cf_sql_char" );
			queryObj.addParam( name="condition", value=keyword&"%", cfsqltype="cf_sql_varchar" );
			rs_student = queryObj.execute( sql=sql ).getResult();
		}
	
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('taskClassDetail', targetArgs)#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">教学任务调整</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 info"></i>确认要添加的学生
				</h2>
			</div>
		</div>
	</div>
</div>

<!--- 加载导航菜单 --->
<!-- stepMenu-->
<cfoutput>#event.getArg("stepMenu")#</cfoutput>
<!--/stepMenu-->

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="create">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labStudent">class="active"</cfif> id="labStudent" tabTarget="Student">查找学生</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					
					// -->
					//]]>
				</script>
				
				<div id="Student" class="tabContent">
				
					<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('applyWizardByCourse', targetArgs)#</cfoutput>">
						<input type="hidden" name="TabID" value="labStudent" />
						
						<div class="label">
							<b>学号或姓名</b>
							<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
						</div>
						<hr/>
						<div class="lable">
							<input class="button1" type="submit" value="搜索" />
						</div>
					</form>
					
					<cfif rs_student.recordCount>

						<div class="clearfix">
							<div class="UICardTable">
                                <cfloop query="rs_student">
									
									<cfset structInsert(targetArgs, "STU", rs_student.stu_id, true) />
									<cfset propertyAdvice.parseProperty(rs_student.student_prop) />
									
									<dl <cfif not propertyAdvice.getInSchool()>class="disabled"</cfif>>
										<dt>
											<a href="<cfoutput>#buildURL('applyWizardByCourseDetail', targetArgs)#</cfoutput>">
												<em class="people"><!--imgholder--></em>
												<dd>
													<h3><cfoutput>#rs_student.stu_name#</cfoutput> - <cfoutput>#rs_student.cls_name#</cfoutput></h3>
													<p><cfoutput>#rs_student.stu_id#</cfoutput></p>
												</dd>
											</a>
										</dt>
									</dl>
								</cfloop>					
							</div>
						</div>
					
					</cfif>
					
				</div>
				
			</div>
		</li>
	</ul>
</div>